<template>
  <div>
    <!-- 操作栏 -->
    <div style="margin-bottom: 20px">
      <el-button type="primary" @click="onSubmit">批量通过</el-button>
      <el-button type="primary" @click="onSubmit">批量驳回</el-button>
    </div>
    <!-- 信息栏 -->
    <div class="infoma-style">
      <div class="infoma-left">
        <img
          src="../../assets/patentReview/orange.png"
          alt=""
          style="width: 16px; height: 16px; padding-right: 3px"
        />
        <div>已选择{{ toltalNumber }}个信息</div>
      </div>
      <div>
        <el-button type="text" @click="watchSelectedInfo"
          >查看已选信息</el-button
        >
        <el-button type="text" @click="deleteSelected">删除已选</el-button>
      </div>
    </div>
    <!-- 具体内容 -->
    <table-item
      :tableData="tableData"
      @passSelectedInfo="passSelectedInfo"
    ></table-item>

    <!-- 查看弹框 -->
    <el-dialog title="查看已选信息" :visible.sync="dialogVisible" width="70%">
      <table-item
        :tableData="selectedInfomation"
        :isWatchSelected="true"
      ></table-item>
      <span slot="footer" class="dialog-footer">
        <el-button @click="dialogVisible = false">取 消</el-button>
        <el-button type="primary" @click="dialogVisible = false"
          >确 定</el-button
        >
      </span>
    </el-dialog>
  </div>
</template>

<script>
import TableItem from "./tableItem.vue";
export default {
  components: {
    TableItem,
  },
  data() {
    return {
      selectedInfomation: [],
      toltalNumber: 0,
      dialogVisible: false,
      tableData: [
        {
          applicant: "深圳市蓝天白云股份有限公司",
          source: "中国南方知识产权局",
          time: "2022-09-09 22:22:22",
          material: "专利授权材料.pdf",
          reviewStatus: 0,
          checked: false,
          detailData: [
            {
              number: "CN202223003838.0",
              name: "一种利用复合菌培养液处理养殖废水的方法",
              status: 1,
              checkStatus: false,
            },
            {
              number: "CN202223003838.0",
              name: "一种利用复合菌培养液处理养殖废水的方法",
              status: 1,
              checkStatus: false,
            },
            {
              number: "CN202223003838.0",
              name: "一种利用复合菌培养液处理养殖废水的方法",
              status: 1,
              checkStatus: false,
            },
            {
              number: "CN202223003838.0",
              name: "一种利用复合菌培养液处理养殖废水的方法",
              status: 1,
              checkStatus: false,
            },
          ],
        },
        {
          applicant: "南京市蓝天白云股份有限公司",
          source: "中国南方知识产权局",
          time: "2022-09-09 22:22:22",
          material: "专利授权材料.pdf",
          reviewStatus: 1,
          checked: false,
          detailData: [
            {
              number: "CN202223003838.0",
              name: "一种利用复合菌培养液处理养殖废水的方法",
              status: 2,
              checkStatus: false,
            },
            {
              number: "CN202223003838.0",
              name: "一种利用复合菌培养液处理养殖废水的方法",
              status: 2,
              checkStatus: false,
            },
            {
              number: "CN202223003838.0",
              name: "一种利用复合菌培养液处理养殖废水的方法",
              status: 2,
              checkStatus: false,
            },
            {
              number: "CN202223003838.0",
              name: "一种利用复合菌培养液处理养殖废水的方法",
              status: 2,
              checkStatus: false,
            },
          ],
        },
        {
          applicant: "南京市蓝天白云股份有限公司",
          source: "中国南方知识产权局",
          time: "2022-09-09 22:22:22",
          material: "专利授权材料.pdf",
          reviewStatus: 2,
          checked: false,
          detailData: [
            {
              number: "CN202223003838.0",
              name: "一种利用复合菌培养液处理养殖废水的方法",
              status: 1,
              checkStatus: false,
            },
            {
              number: "CN202223003838.0",
              name: "一种利用复合菌培养液处理养殖废水的方法",
              status: 2,
              checkStatus: false,
            },
            {
              number: "CN202223003838.0",
              name: "一种利用复合菌培养液处理养殖废水的方法",
              status: 2,
              checkStatus: false,
            },
            {
              number: "CN202223003838.0",
              name: "一种利用复合菌培养液处理养殖废水的方法",
              status: 1,
              checkStatus: false,
            },
          ],
        },
      ],
    };
  },
  methods: {
    passSelectedInfo(val) {
      this.selectedInfomation = val;
      // 计算已选信息的总条数
      this.toltalNumber = 0;
      this.selectedInfomation.forEach((item) => {
        this.toltalNumber += item.detailData.length;
      });
    },
    // 查看已选信息
    watchSelectedInfo() {
      
      if(this.selectedInfomation.length !== 0 ) {
        this.dialogVisible = true;
      }else{
        alert('请选择')
      }
    },
    // 删除已选
    deleteSelected() {
      // 清空已经选择的
      this.selectedInfomation = [];
      this.toltalNumber = 0;
      // 改变组件中的checkbox值
      this.tableData.forEach((item) => {
        item.checked = false;
        item.detailData.map((itemchild) => {
          itemchild.checkStatus = false;
        });
      });
    },
    onSubmit() {},
  },
};
</script>

<style scoped>
.infoma-style {
  display: flex;
  height: 40px;
  justify-content: space-between;
  align-items: center;
  background: rgba(255, 172, 7, 0.04);
  padding: 0 16px;
  border-radius: 4px;
  border: 1px solid rgba(255, 172, 7, 0.65);
}
.infoma-left {
  display: flex;
  align-items: center;
}
::v-deep .el-collapse-item__header {
  background: #f7f7f7;
  box-shadow: inset 0px -1px 0px 0px #eaeaea;
  justify-content: space-between;
  padding: 0 0 0 8px;
  font-size: 14px;
}
::v-deep .el-collapse-item__arrow {
  margin: 0 8px 0 0;
}
::v-deep .el-collapse-item__content {
  padding: 0;
}

::v-deep .el-pagination {
  display: flex;
  justify-content: right;
}
</style>
